package com.wtwd.device.service;


import com.wtwd.device.model.vo.LoginVO;

import java.util.Map;
import java.util.concurrent.TimeUnit;

public interface RedisService {


    void setKey(String key, String value, long expireTime, TimeUnit timeUnit);

    void setKey(String key, String value, long expireTime);

    void setHash(String key, Map<String, Object> map, long expireTime, TimeUnit timeUnit);

    boolean hasKey(String key);

    String getValue(String key);




    /**
     * 删除键
     *
     * @param key
     * @return
     */
    boolean deleteKey(String key);

    LoginVO createLoginToken(Long userId);

    /**
     * 校验验证码
     *
     * @param account
     * @param authType
     * @return
     */
    boolean verifyCode(String account, int authType, String code);

    /**
     * 创建验证码
     *
     * @param account
     * @param authType
     * @return
     */
    boolean createCode(String account, int authType, String code, long expireTime);

    boolean lock(String key, String value, long expireTime);

    boolean unlock(String key, String value);

    /**
     * 原子递增
     * @param key
     * @return
     */
    long increment(String key);

    Map<String,Object> getHashValue(String key);

    /**
     * 保存缓存
     *
     * @param key
     * @param hashKey
     * @param object
     */
    void saveCache(String key, String hashKey, Object object);
}
